#include "stdafx.h"

FadeAnimation::FadeAnimation(int x, int y)
	:x(x), y(y)
{

}

FadeAnimation::~FadeAnimation()
{

}

bool FadeAnimation::update(double dtime)
{
	time += dtime;

	if (time > lasting)
	{
		return false;
	}

	alpha = 1.0f - time / lasting;
}

bool FadeAnimation::render()
{
	ProgramMgr::getInstance()->get("img")->uniform1f("transparency", alpha);

	img->render(x, y, width, height);

	ProgramMgr::getInstance()->get("img")->uniform1f("transparency", 1.0f);

	return true;
}